﻿@model MVCApp.Models.Person

@{
    int districtId = ViewBag.DistrictId;
    string districtName = ViewBag.DistrictName;

    Model.PostCode = ViewBag.DistrictPostCode;
}

<div id="addPersonWrapper" class="clear-fix" style="display:none">

    <div id="addPersonMap" class="float-right">
        <div class="addPersonMapCanvas"></div>
    </div>

    <div id="addPersonFormWrapper" class="float-left">
        @using (Ajax.BeginForm("AddPerson", null, new AjaxOptions { 
            OnBegin = "validatePerson",     
            OnSuccess = "personAdded",
            OnFailure = "personAddError",
            LoadingElementId = "ajaxLoader"},
            new { id = "addPersonForm" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)

            <fieldset>
                <legend>Add person</legend>

                <div class="editor-label">
                    <label>@Strings.PersonNameSurname</label>
                </div>
                <div class="editor-field">
                    <input id="NameSurname" type="text"/>
                </div>

                @Html.HiddenFor(model => model.District.Id, new { Value = districtId })
                @Html.HiddenFor(model => model.Name)
                @Html.HiddenFor(model => model.Lastname)
                @Html.HiddenFor(model => model.Latitude, new { data_geo = "lat" })
                @Html.HiddenFor(model => model.Longitude, new { data_geo = "lng" })
                @Html.HiddenFor(model => model.PostCode, new { data_geo = "postal_code" })
                @Html.HiddenFor(model => model.StreetAddress)
        
                <input id="Route" name="Route" type="hidden" data-geo="route">
                <input id="StreetNumber" name="StreetNumber" type="hidden" data-geo="street_number">

                <div class="editor-label">
                    @Html.LabelFor(model => model.StreetAddress)
                </div>
                <span class="field-validation-error" hidden="hidden" id="GeoCompleteValidationError"></span>
                <input id="geocomplete" type="text" placeholder="@Strings.AutocompleteAddressEnterLocation" />                
                <input id="StreetNumberDetails" type="text" placeholder="@Strings.AutocompleteAddressEnterLocationDetails" />

                <div class="editor-label">
                    @Html.LabelFor(model => model.TelephoneNumber)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.TelephoneNumber)
                    @Html.ValidationMessageFor(model => model.TelephoneNumber)
                </div>

                <p>
                    <input type="submit" value="@Strings.AddPerson" />
                    <span id="addPersonInfoMessage" class="infoMessage" style="display:none"></span>
                </p>
                
            </fieldset>
        }
    </div>
     
</div>